
import {
    getMesPropertyList
} from '@/api/process/mesTechnologyCharacteristic'

export const mesModelInventoryDialog = {
    data(){
        return {
            mesPropertyDialogVisible:false,
            getMesPropertyList,
            hasMesPropertyFooter:true,
            mesPropertySearchDialog:{
                inline: true,
                formDesc: {
                    characteristicCode: {
                        type: "input",
                        layout: 8,
                        label: $i18n.t("mesTechnologyCharacteristic.characterCode"),
                    },
                    characteristicName: {
                        type: "input",
                        layout: 8,
                        label: $i18n.t("mesTechnologyCharacteristic.characterName"),
                    },
                }
            },
            mesPropertyDialogColumn:[
                {
                    type: "selection",
                },
                {
                    type: "index",
                    label: $i18n.t('common.order'),
                    fixed: "left",
                },
                {
                    prop: "propCode",
                    label: $i18n.t("mesTechnologyCharacteristic.materialCode"),
                    minWidth: 150,
                    showOverflowTooltip: true
                },
                {
                    prop: "propName",
                    label:$i18n.t("mesTechnologyCharacteristic.materialName"),
                    minWidth: 250,
                    showOverflowTooltip: true
                },
                {
                    prop: "characteristicCode",
                    label: $i18n.t("mesTechnologyCharacteristic.characterCode"),
                    minWidth: 150,
                    showOverflowTooltip: true
                },
                {
                    prop: "characteristicName",
                    label:$i18n.t("mesTechnologyCharacteristic.characterName"),
                    minWidth: 250,
                    showOverflowTooltip: true
                }
            ]
        }
    },
    methods: {
        // 弹框表格，双击表格，或者点击确定 返回选中数据
        getSelectMesProperty(data) { 
            // 调试完成记得删除控制台打印
            //console.log("选中数据", data);
            // 这里可以自定义返回字段信息 
            // 第一个入参为当前表单绑定的对象，第二个入参为要修改的字段名，第三个入参为选中数据中相应信息
            for(let row of data){
                if(!!this.formDataDialog.characteristicList){
                    let item=this.formDataDialog.characteristicList.find(v=>v.propCode==row.propCode
                        &&v.characterCode==row.characteristicCode);
                        console.log(item,'item')
                    if(!item){
                        this.formDataDialog.characteristicList.push({
                            "propCode": row.propCode,
                            "propName": row.propName,
                            "characterCode": row.characteristicCode,
                            "characterName": row.characteristicName,
                            "isReport":0,
                            "displayOrder":this.formDataDialog.characteristicList.length+1
                        });
                    }
                }else{
                    this.formDataDialog.characteristicList =[{
                        "propCode": row.propCode,
                        "propName": row.propName,
                        "characterCode": row.characteristicCode,
                        "characterName": row.characteristicName,
                        "isReport":0,
                        "displayOrder":"1"
                    }];
                }
            }
        },
    }

}

